Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 4d86f31330d96815e7374e4c2f8a33d5c28372de


Parents : 0eae784
Author : Ivan <ivan@quad4.io>
Signature : Invalid signer <e46112d44649266d71fe2193e00a4710>, author is <ivan@quad4.io>
Date : 2026-07-08T17:56:50-05:00

fix(Self-Check): add checks for None values in identity hash and private key during identity file roundtrip, ensuring robust error handling and preventing potential failures.

Changes

1 files changed, 12 insertions(+), 3 deletions(-)


Diff

diff --git a/meshchatx/src/backend/self_check.py b/meshchatx/src/backend/self_check.py
index dd7c9858..09d33568 100644
--- a/meshchatx/src/backend/self_check.py
+++ b/meshchatx/src/backend/self_check.py
@@ -373,12 +373,21 @@ def check_identity_file_roundtrip(base_dir: str | None = None) -> dict[str, str]
)
os.close(fd)
identity = RNS.Identity(create_keys=True)
- original = bytes(identity.hash)
+ orig_hash = identity.hash
+ if orig_hash is None:
+ return _status(False, "Generated identity hash is None")
+ original = bytes(orig_hash)
+ priv_key = identity.get_private_key()
+ if priv_key is None:
+ return _status(False, "Generated private key is None")
with open(path, "wb") as handle:
- handle.write(identity.get_private_key())
+ handle.write(priv_key)
loaded = RNS.Identity(create_keys=False)
loaded.load(path)
- if bytes(loaded.hash) != original:
+ loaded_hash = loaded.hash
+ if loaded_hash is None:
+ return _status(False, "Loaded identity hash is None")
+ if bytes(loaded_hash) != original:
return _status(False, "Reloaded identity hash mismatch")
return _status(True)
except Exception as exc:


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────